/*** Trigger Name: ifulfillRestrictEditWTask 
 * Author: Accenture
 * Date: 10-feb-2012
 * Requirement/Project Name: iFulfill
 * Requirement Description: 
 **/
trigger ifulfillRestrictEditWTask on Wokflow_Steps__c (before update)
{
    list<Workflow_Stage__c> wfstageList = new list<Workflow_Stage__c>();
    Set<ID> wfId = new Set<Id>(); 

    for(Wokflow_Steps__c wfStepObj: trigger.new) 
    {     
         wfId.add(wfStepObj.Wokflow_Stage_Name__c); 
    }
    wfstageList =[Select id from Workflow_Stage__c where  (Workflow_Code__r.status__c ='Inactive' or Workflow_Code__r.status__c ='Pending Inactivation') and id in :wfId]; 
    wfId.clear(); 
    for(Workflow_Stage__c wfStepObj: wfstageList ) 
    {     
        wfId.add(wfStepObj.id); 
    }   
    for(Wokflow_Steps__c wfStepObj: trigger.new) 
    {      
         // check if workflow is inactive or pending inactive status
        if(wfID.contains(wfStepObj.Wokflow_Stage_Name__c))      
        {   
           wfStepObj.adderror('Cannot edit workflow task if assocaited Workflow is in Pending Inactive or Inactive status');      
        }  
    }
}